from nest.path.parser import PathParser


DOT = '.'
ARROW = '->'
STROKE = '/'
BACKSLASH = '\\'


class PartitionParser(PathParser):

    path_sep = DOT

    def __assert_path_type(self):
        if not isinstance(self._path, basestring):
            # TODO: Consider a fast check for "splitable" interface, 
            # i.e. _path has a split() method.
            raise TypeError('StrokeParser expects path to be a string.')
 
    def parse(self):
        self.__assert_path_type()
        self.path_head, self.path_tail = self._path\
            .partition(self.path_sep)[::2]
            
    def join(self, keys):
        key_strs = (str(key) for key in keys)
        return self.path_sep.join(key_strs)
